//
//  SmsCloudLongImgController.m
//  smsCloud
//
//  Created by 吴斌 on 2024/7/20.
//

#import "SmsCloudLongImgController.h"

@interface SmsCloudLongImgController ()
@property (nonatomic, strong)UIImageView * smsCloudLongImgView;
@end

@implementation SmsCloudLongImgController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBar.hidden = YES;
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.view.backgroundColor = [SmsCloudHead SmsCloudColorHexString:@"#FFFFFF"];
    [self smsCloudInitView];
}
- (void)smsCloudInitView{
    UIScrollView *longImgScrollView = [[UIScrollView alloc] init];
    longImgScrollView.showsVerticalScrollIndicator = false;
    longImgScrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    longImgScrollView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
    [self.view addSubview:longImgScrollView];
    [longImgScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(@([SmsCloudHead SmsCloudScreewRatio:0]));
    }];
    UIView *longImgScrollContentView = [[UIView alloc] init];
    longImgScrollContentView.backgroundColor = [UIColor clearColor];
    [longImgScrollView addSubview:longImgScrollContentView];
    [longImgScrollContentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(@([SmsCloudHead SmsCloudScreewRatio:0]));
    }];
    
    self.smsCloudLongImgView = [[UIImageView alloc] init];
    self.smsCloudLongImgView.userInteractionEnabled = true;
//    self.smsCloudLongImgView.contentMode = UIViewContentModeScaleAspectFill;
    [longImgScrollContentView addSubview:self.smsCloudLongImgView];
    [self.smsCloudLongImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@([SmsCloudHead SmsCloudScreewRatio:0]));
        make.width.equalTo(@([SmsCloudHead SmsCloudScreewWidth]));
        make.top.equalTo(@([SmsCloudHead SmsCloudScreewRatio:0]));
        make.bottom.equalTo(@([SmsCloudHead SmsCloudScreewRatio:0]));
    }];
    UIImage * longImg = [SmsCloudHead SmsCloudImageNamed:self.longImgName];
    self.smsCloudLongImgView.image = longImg;
    CGFloat longImgHeight = [SmsCloudHead SmsCloudScreewWidth] *(longImg.size.height/(CGFloat)longImg.size.width);
    longImgScrollView.contentSize = CGSizeMake(0, longImgHeight);
    
    UIButton * smsCloudLongBackBtn = [[UIButton alloc] init];
    [smsCloudLongBackBtn setBackgroundImage:[SmsCloudHead SmsCloudImageNamed:@"smsCloudNavBlackBack"] forState:UIControlStateNormal];
    [smsCloudLongBackBtn addTarget:self action:@selector(smsCloudLongBack) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:smsCloudLongBackBtn];
    [smsCloudLongBackBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@([SmsCloudHead SmsCloudScreewRatio:24]));
        make.top.equalTo(@([SmsCloudHead SmsCloudScreewRatio:22] + [SmsCloudHead SmsCloudTopSafeH]));
        make.width.equalTo(@([SmsCloudHead SmsCloudScreewRatio:64]));
        make.height.equalTo(@([SmsCloudHead SmsCloudScreewRatio:64]));
    }];
}
- (void)smsCloudLongBack{
    [self.navigationController popViewControllerAnimated:true];
}
@end
